#include<iostream>
#include<cmath>
#include<algorithm>
#include<unordered_map>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
int arr[N];
unordered_map<LL, int>mp;
int k;
int n, m;
int main()
{
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	sort(arr + 1, arr + 1 + n);
	for (int i = 1; i <= n; i++) {
		if (i == 1)mp[arr[i]] = 1;
		else {
			mp[arr[i]] = max(mp[arr[i] - k] + 1, mp[arr[i]]);
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = max(ans, mp[arr[i]]);
	}
	cout << ans << endl;
	return 0;
}